package ca.ets.osgi.planeservice;

import java.util.Hashtable;

/**
 * 
 * @author HP_Administrator
 *
 */
public class ListAirport {
	
	//
	private Hashtable<String,Airport> aTable = new Hashtable<String,Airport>();
	
	
	//
	private static ListAirport instance;
	
	//
	private ListAirport(){}
	
	/**
	 * Create a list of airports
	 * @return the list
	 */
	public static ListAirport getInstance(){
		if(instance ==null)
			instance = new ListAirport();
		return instance;
	}
	
	
	
	/**
	 * @return the aTable
	 */
	public Hashtable<String, Airport> getaTable() {
		return aTable;
	}

	/**
	 * @param aTable the aTable to set
	 */
	public void setaTable(Hashtable<String, Airport> aTable) {
		this.aTable = aTable;
	}

	/**
	 * Add an airport to the list
	 * @param code
	 * @param aport
	 */
	public void addAirportToList(String code, Airport aport){
		this.aTable.put(code, aport);
	}

	
	/**
	 * Remove an airport from the list
	 * @param code
	 */
	public void removeAirportFromList(String code){
		this.aTable.remove(code);
	}
	
	/**
	 * Return an Airport if it's present
	 * @param name the name of the airport
	 * @return the Airport
	 */
	public Airport getAnAirport(String name){
		return this.aTable.get(name);
	}
	
	/**
	 * Return the Airport ID of the Airport
	 * @param name
	 * @return
	 */
	public String getAirportName(String name){
		return this.getAnAirport(name).getAirportID();
	}
}
